package com.lwt.service.serviceImpl;

import com.lwt.dao.base.dao.StudentDao;
import com.lwt.dao.base.dao.daoImpl.StudentDaoImpl;
import com.lwt.pojo.Student;
import com.lwt.service.StudentService;

import javax.sound.midi.Soundbank;
import java.util.List;

/**
 * @Author Li Weitong
 * @Date 2020/11/22 12:41
 */
public class StudentServiceImpl implements StudentService {
    private StudentDao studentDao = new StudentDaoImpl();
    @Override
    public void addStudent(Student student) {
        studentDao.addStudentInfo(student);
    }

    @Override
    public int deleteStudentById(Integer studentId) {
        int i = studentDao.deleteStudentById(studentId);
        if (i>0) {
            System.out.println("删除成功");
            return 1;
        }else {
            System.out.println("删除失败");
        }
        return -1;
    }

    /**
     *
     * @param student
     * @return 修改成功返回true
     */
    @Override
    public int updateStudent(Student student) {
        int i = studentDao.updateStudent(student);
        if (i > 0) {
            System.out.println("修改成功");
            return 1;
        }else {
            System.out.println("修改失败");
        }
        return -1;
    }

    @Override
    public Student queryStudentById(Integer studentId) {
        return studentDao.queryStudentById(studentId);
    }

    @Override
    public Student queryStudnetByName(String studentName) {
        return studentDao.queryStudentByName(studentName);
    }

    @Override
    public List<Student> queryStudentByGradeId(Integer gradeId) {
        return studentDao.queryStudentByGradeId(gradeId);
    }

    @Override
    public List<Student> queryStudentList() {
        return studentDao.queryStudentList();
    }
}
